package org.example.controller;


import org.example.domain.Result;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import org.example.domain.UtuFollower;
import org.example.service.IUtuFollowerService;

import java.util.List;


/**
 * 被关注Controller
 *
 * @author coderfun
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/user_to_user/follower")
public class UtuFollowerController {
    @Autowired
    private IUtuFollowerService utuFollowerService;

    /**
     * 查询被关注列表
     */
//    @PreAuthorize("@ss.hasPermi('system:follower:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(UtuFollower utuFollower)
//    {
//        startPage();
//        List<UtuFollower> list = utuFollowerService.selectUtuFollowerList(utuFollower);
//        return getDataTable(list);
//    }

    /**
     * 获取被关注详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:follower:query')")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id) {
        return Result.success(utuFollowerService.selectUtuFollowerById(id));
    }

    /**
     * 新增被关注
     */
    @PreAuthorize("@ss.hasPermi('system:follower:add')")
    @PostMapping
    public Result add(@RequestBody UtuFollower utuFollower) {
        return Result.success(utuFollowerService.insertUtuFollower(utuFollower));
    }

    /**
     * 修改被关注
     */
    @PreAuthorize("@ss.hasPermi('system:follower:edit')")
    @PutMapping
    public Result edit(@RequestBody UtuFollower utuFollower) {
        return Result.success(utuFollowerService.updateUtuFollower(utuFollower));
    }

    /**
     * 删除被关注
     */
    @PreAuthorize("@ss.hasPermi('system:follower:remove')")
    @DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids) {
        return Result.success(utuFollowerService.deleteUtuFollowerByIds(ids));
    }

    /**
     * 查询粉丝列表
     */
    @PreAuthorize("@ss.hasPermi('system:follower:list')")
    @GetMapping("/list")
    public Result selectFlowerList(UtuFollower utuFollower) {
        List<UtuFollower> list = utuFollowerService.selectFlowerList(utuFollower);
        return Result.success(list);
    }
}
